<?php
	$cvename = $_GET['cve'];
	$pagelink = $_GET['link'];
	if($cvename==null || $cvename=='' || $pagelink==null || $pagelink==''){
		echo 'No CVE has been spacified.';
	}else{
?>

<html>

<head>
	
	<script type="text/javascript" src="jquery.js"></script>
	
	<style type="text/css"> 
	            
       #pageinfo{
            margin:5px;
			padding:5px;
			background:#F5F5DC;
			border:solid 2px #c3c3c3;
        }	
	   table,td,th{
			margin:5px;
			padding:5px;
			border:solid 2px #191970; 
			border-collapse:collapse;
			background-color:#F8F8FF;
	   }
	   table{
			width:99%;
	   }
	   th{
			width:50%;
			text-align:left;
			background-color: #c3c3c3;
	   }
	   td{
			width:50%
	   }
	</style>

</head>

<body>
	
	<?php
            global $global_ws_address;

			$context = stream_context_create(array(
				'http' => array(
					'timeout' => 10      // Timeout in seconds
				)
			));

			$url = $global_ws_address.'o=pageinfo&p1='.$cvename.'&p2='.$pagelink;
			$result = @file_get_contents($url,0,$context);
			$result = json_decode($result, true);
			if(!is_array($result)){
				echo 'No results';
			}else{
	?>
	<br/>
	<h3><?php echo $result['cvename'].' > Link'.$result['rank'].' Details'?></h3>

	<div id="pageinfo">
		<b>Page Title: </b><?php echo $result['title']?><br/>
		<b>Website: </b><?php echo $result['web']?><br/>
		<b>URL: </b><?php echo $result['url']?><br/>
		<br/>
		<b>Page Detail</b> (last updated: <?php echo $result['last_update']?>)<br/>
		<table>
			<?php
				$result = array_slice($result,8,25);
				$comp = array('','BASIC','TECH','EXP','PUBLIC','REMEDIATION');
				$fullComp = array('','Basic Information','Technical Information','Exploit Information','Publicity Information','Remediation Information');
				foreach($result as $index => $value){
					echo '<tr>';
					$isComp = array_search($index,$comp);
					if($isComp==null) echo '<th>'.$index.'</th>';
					else echo '<th style="background-color:#e5eecc">'.$fullComp[$isComp].'</th>';
					echo '<td>'.$value.'</td>';
					echo '</tr>';
				}
			?>
		</table>
	</div>

	<a href="javascript:history.go(-1)"><< BACK TO PREVIOUS PAGE</a>

</body>

</html>
<?php
			}
	}	
?>